﻿using Landpy.CruiseControlNet.ConfigurationSidekick.ConfigTreeModule;
using Landpy.CruiseControlNet.ConfigurationSidekick.ParserModule;

namespace Landpy.CruiseControlNet.ConfigurationSidekick.ConfigPropertyModule
{
    class EmailGroupHandler : GetPropertiesHandler
    {
        public override object GetPropertiesObject(GetPropertiesContext getPropertiesContext)
        {
            var treeNodeIndentity = this.GetTreeNodeIndentity(getPropertiesContext);
            if (treeNodeIndentity.Type == TreeNodeType.EmailGroup)
            {
                EmailGroupKey emailGroupKey = EmailGroupKeyUtil.GetKey(treeNodeIndentity.Key);
                return this.EmailGroupRepository.GetGroupById(getPropertiesContext.CruiseControl, emailGroupKey.ProjectId,
                                                  emailGroupKey.EmailId, emailGroupKey.Id);
            }
            return this.Successor.GetPropertiesObject(getPropertiesContext);
        }
    }
}
